public class Solution {
    //判断两颗树是否互为镜像
    public boolean IsMirror(TreeNode p,TreeNode q){
        if(p==null&&q==null){
            return true;
        }
        if(p==null||q==null){
            return false;
        }

        return (p.val==q.val)&&(IsMirror(p.left,q.right))&&(IsMirror(p.right,q.left));
    }
    public boolean isSymmetric(TreeNode root) {
        if(root==null){
            return true;
        }
        return IsMirror(root.left,root.right);
    }
}
